package com.hackerrank.challenges.fillingjars;

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), M = in.nextInt();
		long S = 0;
		for(int m = 0; m < M; m++) {
			long a = in.nextInt(), b = in.nextInt(), k = in.nextInt();
			S += (b - a + 1) * k;
		}
		System.out.println(S / N);
	}
}
